email me at borlaj@portlandschools.org
notes previous (09/07/06) submit the dump links  
 

Project Craps - 10 points:

 

This is due Thursday beginning of class. You can reuse much code from Blackjack.

 

You are going to create a text based craps game. Lets first review the rules of craps.

 

In craps a game is won if a 7 or 11 is rolled on the first "come-out" roll and if that first roll is 2, 3 or 12, they lose. If it is not one of those rolls, then that score becomes the point. The person then continues to roll until they roll that point again (in which case they win), or they roll a 7 (in which case they lose).

  1. Initially, start the player with $10,000
  2. Ask them how much they want to bet.
  3. Tell them to hit enter to roll the "come-out roll".
  4. Display the first roll on the screen (if the sum is 7,11 they win if it is 2,3,12 they lose).
  5. If it is not a deciding roll,tell them the point roll is ___ and to hit enter to roll again
  6. If it is the point roll, tell them they won, if it is a 7, tell them they lose. Otherwise go to 4
  7. Display the amount of money they have and repreat 2 (if they have positive money)
  8. Give them a sentinal (-1) to quit.

Create this all in a class Craps. You will need at least these methods:

  • method rollDice which returns the sum and prints out the roll of each of the 2 dice.
  • method findBet that will return they amount the want to bet or -1 if they want to quit
  • method printInstructions that will display the instructions of craps
  • method isWinner that will play one hand of the game and return true or false.
  • method craps that runs the game. It takes no arguments and returns nothing.

Hints

To pause and wait for them to hit enter:

System.out.println("Hit enter to continue");

scan.nextLine();

 

Rubric: (10 points)

  • findBet, printInstructions,rollDice work correctly 1 point each
  • isWinner plays a game correctly, works as described (2 points)
  • the method craps calls the methods above executes correctly. (2 points)
  • code is indented properly - 1point
  • variable and code named approp 1 point
  • code is commented 1 point